%{
#include "GrammarAnalyzer.h"
#include "yyparse.h"
#include <stdio.h>
extern YYSTYPE yylval;
%}

digit		[0-9]
letter		[a-zA-Z]
number		{digit}+
double		{number}(\.){number}
identifier	{letter}+{digit}*{letter}*{digit}*
newline		\n
whitespace	[ \t]+

%%

"int"		{return INT;}
"float"		{return FLOAT;}
"main"		{return MAIN;}
"if"		{return IF;}
"else"		{return ELSE;}
"while"		{return WHILE;}
"break"		{return BREAK;}
"continue"	{return CONTINUE;}
"return"	{return RETURN;}
"=="		{return EQ;}
"<"		{return LT;}
"<="		{return LE;}
"="		{return '=';}
"+"		{return '+';}
"-"		{return '-';}
"*"		{return '*';}
"/"		{return '/';}
"%"		{return '%';}
"("		{return '(';}
")"		{return ')';}
"["		{return '[';}
"]"		{return ']';}
"{"		{return '{';}
"}"		{return '}';}
","		{return ',';}
";"		{return ';';}

{number}	{
			::sscanf(yytext, "%d", &yylval.intVal);
			return INT_NUMBER;
		}
{double}	{
			::sscanf(yytext, "%lf", &yylval.doubleVal); 
			return FLOAT_NUMBER;
		}
{identifier} 	{	
			//::sscanf(yytext, "%s", yylval.strVal);
			yylval.strVal = yytext;
			return ID;
		}
{whitespace} 	{/* skip whitespace */}
{newline}	{yylineno++;}
%%

int yywrap(void)
{
	return 1;
}
